package com.ld.front.controller.tool;

import java.io.IOException;

import javax.servlet.ServletException;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ld.common.controller.ProjectBasicController;
import com.ld.common.model.json.ApiResult;
import com.ld.shieldsb.common.core.util.StringUtils;
import com.ld.shieldsb.dao.model.QueryModel;
import com.ld.tool.model.tool.ShieldjsDemoModel;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 数据库工具服务
 * 
 * @ClassName TimedTaskController
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2019年4月26日 上午11:04:24
 *
 */
@Api(tags = "shieldjs示例服务") // description 必填 文档显示 标题
@RestController
@RequestMapping("${shieldsb.frontPath}/tool/shieldjsdemo")
public class ShielsjsDemoController extends ProjectBasicController<Object> {

    @ApiOperation(value = "获取shieldjs示例", notes = "") // value 必填文档显示
    @RequestMapping(path = "", method = RequestMethod.GET)
    // 返回json格式
    public ApiResult<ShieldjsDemoModel> getDemo(@ApiParam(name = "name", value = "shieldjs方法", required = true) @RequestParam String name)
            throws ServletException, IOException {
        name = name.trim();
        if (StringUtils.isEmpty(name)) {
            return ApiResult.err("name不能为空", null);
        }
        QueryModel queryModel = basicService.getNormalQueryModel();
        queryModel.addEq("pluginKey", name); // 列名
        ShieldjsDemoModel model = basicService.getOne(ShieldjsDemoModel.class, queryModel);
        return ApiResult.ok(model);
    }

}
